Class TreeQueryableBase<TProps>

Assembly: redb.Core.dll

Base tree queryable for hierarchical LINQ queries.
Extends RedbQueryable with tree operation support.

public class TreeQueryableBase<TProps> : RedbQueryable<TProps>, IOrderedRedbQueryable<TProps>, IRedbQueryable<TProps> where TProps : class, new()

Inheritance

ObjectRedbQueryable<TProps>TreeQueryableBase<TProps>

Implements

Methods

AllAsync(Expression<Func<TProps, bool>>)

Check if ALL records match condition.

public override Task<bool> AllAsync(Expression<Func<TProps, bool>> predicate)

AnyAsync()

Check if any records exist.

public override Task<bool> AnyAsync()

AnyAsync(Expression<Func<TProps, bool>>)

Check if any records match condition.

public override Task<bool> AnyAsync(Expression<Func<TProps, bool>> predicate)

BuildTreeExpression()

Build expression for tree query

protected virtual Expression BuildTreeExpression()

CountAsync()

Count records without loading data.

public override Task<int> CountAsync()

CreateInstance(TreeQueryContext<TProps>)

Creates a new instance with the specified context. Override in derived classes.

protected virtual TreeQueryableBase<TProps> CreateInstance(TreeQueryContext<TProps> context)

DeleteAsync()

Delete objects without loading data

public override Task<int> DeleteAsync()

Distinct()

Get distinct values (by all object fields).

public override IRedbQueryable<TProps> Distinct()

DistinctBy<TKey>(Expression<Func<TProps, TKey>>)

DISTINCT ON (field) - one object per unique Props field value.

public override IRedbQueryable<TProps> DistinctBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

DistinctByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

DISTINCT ON (base_field) - one object per unique IRedbObject base field value.

public override IRedbQueryable<TProps> DistinctByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

DistinctRedb()

DISTINCT by IRedbObject base fields (Name, ValueLong, ParentId, etc.) excluding Id.

public override IRedbQueryable<TProps> DistinctRedb()

FirstOrDefaultAsync()

Get first object or null.

public override Task<RedbObject<TProps>?> FirstOrDefaultAsync()

GroupBy<TKey>(Expression<Func<TProps, TKey>>)

Override GroupBy to respect tree context (rootObjectId, maxDepth, ParentIds).

public override IRedbGroupedQueryable<TKey, TProps> GroupBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

GroupByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Override GroupByRedb to respect tree context.

public override IRedbGroupedQueryable<TKey, TProps> GroupByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

OrderBy<TKey>(Expression<Func<TProps, TKey>>)

✅ FIX ISSUE #4: Override OrderBy to preserve Tree context

public override IOrderedRedbQueryable<TProps> OrderBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

OrderByDescending<TKey>(Expression<Func<TProps, TKey>>)

✅ FIX ISSUE #4: Override OrderByDescending for Tree context

public override IOrderedRedbQueryable<TProps> OrderByDescending<TKey>(Expression<Func<TProps, TKey>> keySelector)

OrderByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Sort descending by IRedbObject base fields.

public override IOrderedRedbQueryable<TProps> OrderByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

OrderByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Sort ascending by IRedbObject base fields (id, name, date_create, etc.).

public override IOrderedRedbQueryable<TProps> OrderByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

Select<TResult>(Expression<Func<TreeRedbObject<TProps>, TResult>>)

public IRedbProjectedQueryable<TResult> Select<TResult>(Expression<Func<TreeRedbObject<TProps>, TResult>> selector)

Skip(int)

Skip records.

public override IRedbQueryable<TProps> Skip(int count)

Take(int)

Limit the number of records.

public override IRedbQueryable<TProps> Take(int count)

ThenBy<TKey>(Expression<Func<TProps, TKey>>)

✅ FIX ISSUE #4: Override ThenBy for Tree context

public override IOrderedRedbQueryable<TProps> ThenBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

ThenByDescending<TKey>(Expression<Func<TProps, TKey>>)

✅ FIX ISSUE #4: Override ThenByDescending for Tree context

public override IOrderedRedbQueryable<TProps> ThenByDescending<TKey>(Expression<Func<TProps, TKey>> keySelector)

ThenByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Additional descending sort by IRedbObject base fields.

public override IOrderedRedbQueryable<TProps> ThenByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

ThenByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Additional ascending sort by IRedbObject base fields.

public override IOrderedRedbQueryable<TProps> ThenByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

ToFlatListAsync()

Execute query and get flat list of tree objects

public override Task<List<TreeRedbObject<TProps>>> ToFlatListAsync()

ToListAsync()

Execute query and get list of objects (base RedbObject)

public override Task<List<RedbObject<TProps>>> ToListAsync()

ToListWithProjectionAsync(HashSet<long>?, bool)

Override ToListWithProjectionAsync for correct type conversion

protected override Task<List<RedbObject<TProps>>> ToListWithProjectionAsync(HashSet<long>? projectedStructureIds, bool skipPropsLoading = false)

ToRootListAsync()

Execute query and get list of tree root nodes

public override Task<List<ITreeRedbObject>> ToRootListAsync()

ToTreeListAsync()

Execute query and return filtered objects with populated Parent/Children chains

public override Task<List<TreeRedbObject<TProps>>> ToTreeListAsync()

Where(Expression<Func<TProps, bool>>)

Filter by Props fields.

public override IRedbQueryable<TProps> Where(Expression<Func<TProps, bool>> predicate)

WhereChildrenOf(IRedbObject)

Direct children of specified object.

public override IRedbQueryable<TProps> WhereChildrenOf(IRedbObject parentObject)

WhereChildrenOf(long)

Direct children of specified object.

public override IRedbQueryable<TProps> WhereChildrenOf(long parentId)

WhereDescendantsOf(IRedbObject, int?)

All descendants of specified object (recursive).

public override IRedbQueryable<TProps> WhereDescendantsOf(IRedbObject ancestorObject, int? maxDepth = null)

WhereDescendantsOf(long, int?)

All descendants of specified object (recursive).

public override IRedbQueryable<TProps> WhereDescendantsOf(long ancestorId, int? maxDepth = null)

WhereHasAncestor<TTarget>(Expression<Func<TTarget, bool>>, int?)

Filter by ancestors with polymorphic query support

public override IRedbQueryable<TProps> WhereHasAncestor<TTarget>(Expression<Func<TTarget, bool>> ancestorCondition, int? maxDepth = null) where TTarget : class

WhereHasDescendant<TTarget>(Expression<Func<TTarget, bool>>, int?)

Filter by descendants with polymorphic query support

public override IRedbQueryable<TProps> WhereHasDescendant<TTarget>(Expression<Func<TTarget, bool>> descendantCondition, int? maxDepth = null) where TTarget : class

WhereIn<TValue>(Expression<Func<TProps, TValue>>, IEnumerable<TValue>)

Filter by value in list (WHERE field IN (...)).

public override IRedbQueryable<TProps> WhereIn<TValue>(Expression<Func<TProps, TValue>> selector, IEnumerable<TValue> values)

WhereInRedb<TValue>(Expression<Func<IRedbObject, TValue>>, IEnumerable<TValue>)

Filter by IRedbObject base field in list (WHERE _field IN (...)).

public override IRedbQueryable<TProps> WhereInRedb<TValue>(Expression<Func<IRedbObject, TValue>> selector, IEnumerable<TValue> values)

WhereLeaves()

Leaf nodes only (objects without children).

public override IRedbQueryable<TProps> WhereLeaves()

WhereLevel(Expression<Func<int, bool>>)

Filter by tree level with comparison operator.

public override IRedbQueryable<TProps> WhereLevel(Expression<Func<int, bool>> levelCondition)

WhereLevel(int)

Filter by tree level.

public override IRedbQueryable<TProps> WhereLevel(int level)

WhereRedb(Expression<Func<IRedbObject, bool>>)

Filter by base object fields (Id, Name, ParentId, etc.).

public override IRedbQueryable<TProps> WhereRedb(Expression<Func<IRedbObject, bool>> predicate)

WhereRoots()

Root elements only (parent_id IS NULL).

public override IRedbQueryable<TProps> WhereRoots()

WithLazyLoading(bool)

✅ FIX: Override WithLazyLoading to preserve Tree context

public override IRedbQueryable<TProps> WithLazyLoading(bool enabled = true)

WithMaxDepth(int)

Configure maximum search depth in tree

public override IRedbQueryable<TProps> WithMaxDepth(int depth)

WithMaxRecursionDepth(int)

Configure maximum recursion depth for complex queries ($and/$or/$not).

public override IRedbQueryable<TProps> WithMaxRecursionDepth(int depth)

WithPropsDepth(int)

Configure maximum depth for loading nested RedbObject in Props

public override IRedbQueryable<TProps> WithPropsDepth(int depth)

WithWindow(Action<IWindowSpec<TProps>>)

Override WithWindow to use tree-aware execution.

public override IRedbWindowedQueryable<TProps> WithWindow(Action<IWindowSpec<TProps>> windowConfig)

Constructors